class Poker {
    constructor(number, suit, element) {
        this.number = number
        this.suit = suit
        this.el = element
        this.opened = false
        this.color = this.markedPoker()
        this.currentStack = null
    }
    markedPoker() {
        let colors = {
            spade: 'black',
            heart: 'red',
            club: 'black',
            diamond: 'red',
        }
        return colors[this.suit]
    }
    open() {
        this.el.classList.add('open')
        this.opened = true
        this.el.src = this.el.dataset.src
    }
    smooth() {
        this.el.classList.add('smooth-move')
    }
    quick() {
        this.el.classList.remove('smooth-move')
    }
    highLight() {
        this.el.classList.add('high-light')
        this.el.style.zIndex = '100'
    }
    blur() {
        // log('poker', this)
        this.el.classList.remove('high-light')
        this.el.style.zIndex = '0'
    }
    cover() {
        this.el.classList.remove('open')
        this.opened = false
        this.el.src = 'image/card_back_bg.png'
    }
    twinkle() {
        this.el.classList.add('twinkle')
        setTimeout(() => {
            this.el.classList.remove('twinkle')
        }, 900)
    }
    removeTwinkle() {
        this.el.classList.remove('twinkle')
    }
    isLast() {
        let stack = this.currentStack
        return stack.lastPoker() === this
    }
    isFistOpen() {
        let stack = this.currentStack
        let p = null
        for (let i = 0; i < stack.length; i++) {
            if (stack[i].opened === true) {
                p = stack[i]
                break
            }
        }
        return this === p
    }
}